import java.awt.event.ActionEvent;
import java.net.*;
import java.util.ArrayList;
import java.util.Vector;
import java.io.*;

import javax.swing.*;

public class Server extends MyEvent{
	private JFrame jServerForm;
	private JToggleButton jbtntg;
	private ServerSocket serverSck = null;
	private Socket clientSck = null;
	private boolean isStop = false;
	private Thread runningThread = null;
	private int port = 4000;

	public Server() {
		jServerForm = new JFrame("Server");
		jbtntg = new JToggleButton("Start");
		jbtntg.addActionListener(this);
	}

	public void CreateGUI() {
		jServerForm.add(jbtntg);
		jServerForm.setSize(200, 200);
		jServerForm.setVisible(true);
	}

	public static void main(String[] args) {
		Server server = new Server();
		server.CreateGUI();
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getActionCommand().equals("Start")) {
			jbtntg.setText("Stop");
			System.out.println("Waiting connection...");
			try {
				ServerSocket serverSocket = new ServerSocket(5555);
				Socket clientSocket = serverSocket.accept();
				System.out.println("Client connected :)");
				while (true) {
					ObjectInputStream ois = new ObjectInputStream(clientSocket.getInputStream());
					ObjectOutputStream oos = new ObjectOutputStream(clientSocket.getOutputStream());
				}
		
			} catch (Exception e2) {
				
			}
			
		} else {
			jbtntg.setText("Start");

		}
	}
	
	class ServerHandler  implements  Runnable{

		@Override
		public void run() {
			
		}
		
	}
}
